﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ChongJu.EventManager;
using ChongJu.GlobalInfo;

namespace ChoJu.Single.Views
{
    /// <summary>
    /// AdminView.xaml 的交互逻辑
    /// </summary>
    public partial class AdminView : Window
    {
        public bool Sure { get; private set; }

        public AdminView()
        {
            InitializeComponent();
            CommonEvent.OnMianFromOpacity(true);
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            CommonEvent.OnMianFromOpacity(false);
            this.Close();
        }

        private void btnSure_Click(object sender, RoutedEventArgs e)
        {
            var dt = DateTime.Now;
            var day = dt.Day < 10 ? $"0{dt.Day}" : dt.Day.ToString();
            var min = dt.Minute < 10 ? $"0{dt.Minute}" : dt.Minute.ToString();
            var temp = $"{day}{min}";
            if (tbkMessage.Text == temp)
                Sure = true;
            else
                Sure = false;

            GlobalVar.IsAdmin = Sure;
            CommonEvent.OnMianFromOpacity(false);
            this.Close();
        }

        private void TextBlock_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            var bd = sender as Border;
            var self = bd.Child as TextBlock;
            if (self.Text == "-" & tbkMessage.Text.Length > 0)
                tbkMessage.Text = tbkMessage.Text.Substring(0, tbkMessage.Text.Length - 1);
            else if(self.Text != "-")
                tbkMessage.Text = tbkMessage.Text + self.Text;
        }
    }
}
